
pageQuotaNodesOldObj = {};//创建存放各个页面指标code的对象
function getQuotaData(nodes){
	var quotas = [];
	for(var o in nodes){
		var node = nodes[o];
		var quota = node;
		if(node.checked){
			quotas.push(quota);
			if(node.children || node.isParent){
				getCheckedNodes(node.children, quota);
			}
		}
	}
	function getCheckedNodes(nodes, quotas) {
		quotas.children = [];
		for(var o in nodes){
			var node = nodes[o];
			var quota = node;
			if(node.checked){
				quotas.children.push(quota);
				if(node.children || node.isParent){
					getCheckedNodes(node.children, quota);
				}
			}
		}
	}
	return quotas;
}

//封装页面初始化开始加载指标的方法
function getQuotas(pageCode, loadData,monitorType){
	$.post(contextPath + "/quota/getQuotas.dhc", {pageCode: pageCode}).done(function(data){
		if(data.data.length==0) {
			drgUI.error('没有配置指标,请联系管理员');
		}
		var totalQuota = arrayToTree(data.data, "id", "pid");
		var zTrees = $.extend(true, [], totalQuota);
		totalQuota = getQuotaData(totalQuota);
		loadData(totalQuota);
		loadQuotaSettings(pageCode, loadData, zTrees, totalQuota,monitorType);
	});
}

//加载指标配置页面
function loadQuotaSettings(pageCode, loadData, zTrees, totalQuota,monitorType){
	var quotaSettingBtn = $('<div class="btn-clickable" style="margin:2px;">指标配置<i class="fa fa-cog fa-lg"></i></div>');
	$("#"+tabId+" #hosp-ul").before(quotaSettingBtn);
	if("drgs" == monitorType && ""==paramTabPage[tabId].adrgCode){
		var loadUpperBtn = $('<div class= "btn-clickable" style="margin:2px;">查看ADRG<i class="fa fa-level-up fa-lg"></i></div>');
		$(quotaSettingBtn).before(loadUpperBtn);
		loadUpperBtn.bind('click',function(){
			loadUpperStore(monitorType);
		});
	}else if("adrg" == monitorType && ""==paramTabPage[tabId].mdcCode){
		var loadUpperBtn = $('<div class= "btn-clickable" style="margin:2px;">查看MDC<i class="fa fa-level-up fa-lg"></i></div>');
		$(quotaSettingBtn).before(loadUpperBtn);
		loadUpperBtn.bind('click',function(){
			loadUpperStore(monitorType);
		});
	}
	else if(($("#roles").html()!="科室")&&(("dep" == monitorType&&""==paramTabPage[tabId].depGroupCode&&commonLayerConfig[0]=='1')||("ward" == monitorType&&""==paramTabPage[tabId].depGroupCode&&commonLayerConfig[0]=='1'&&commonLayerConfig[1]=='0'))){
		var loadUpperBtn = $('<div class= "btn-clickable" style="margin:2px;">查看科室组<i class="fa fa-level-up fa-lg"></i></div>');
		$(quotaSettingBtn).before(loadUpperBtn);
		loadUpperBtn.bind('click',function(){
			loadUpperStore(monitorType);
		});
	}
	quotaSettingBtn.bind("click", function(){
		$.post(contextPath+"/pages/common/quota-tree.jsp").done(function(data){
			var dialog  = $(data);
			dialog.find(".modal-title").html("指标配置选项");
			var str = '';
			str += '<div class="zTreeDemoBackground">';
			str += '<ul id="treeDemo" class="ztree"></ul>';
			str += '</div>';
			dialog.find(".echartscq").html(str);
			
			var setting = {
					view: {
						selectedMulti: false
					},
					check: {
						enable: true
					}
				};
			$.fn.zTree.init(dialog.find("#treeDemo"), setting, zTrees);
			
			var zTreeSimp = "";//需要保存的指标数组
			//确定按钮绑定事件
			dialog.find('#save').on('click', function(){
				dialog.find('#save').attr("disabled", true);
				var zTree = $.fn.zTree.getZTreeObj("treeDemo");
				zTrees = zTree.getNodes();
				
				//获取需要保存的指标数组
				zTreeSimp = zTree.transformToArray(zTrees);
				
				//获取选中的指标
				var nodes =  $.extend(true, [], zTrees);
				totalQuota = getQuotaData(nodes);
				
				dialog.trigger('complete');
				
				
			}).end().modal({
				keyboard : false
			}).on({
				'hidden.bs.modal' : function() {
					dialog.remove();
				},
				'complete' : function() {
					//隐藏树弹框
					dialog.modal('hide');
					//正在加载
					
					//循环保存指标
					for(var o in zTreeSimp){
						var node = zTreeSimp[o];
						node.pageCode = pageCode;
						$.post(contextPath + "/quota/saveQuotas.dhc", {param: JSON.stringify(node)}).done(function(data){
						})
					}
					//加载页面指标
					loadData(totalQuota);
	            }
			});
			
			//重置按钮绑定事件
			dialog.find('#clear').on('click', function(){
				drgUI.confirm({
        			content : '即将恢复默认页面指标配置，是否恢复？',
        			callSure : function() {
        				$.post(contextPath + "/quota/clearQuotaSettings.dhc", {pageCode: pageCode}).done(function(data){
        					$.post(contextPath + "/quota/getQuotas.dhc", {pageCode: pageCode}).done(function(data_1){
        						if(data_1.data.length==0){
        							drgUI.error('没有配置指标,请联系管理员');
        							return;
        						}
        						totalQuota = arrayToTree(data_1.data, "id", "pid");
        						var zTrees = $.extend(true, [], totalQuota);
        						$.fn.zTree.init(dialog.find("#treeDemo"), setting, zTrees);
        					});
        				});
        			}
        		});
			});
		})
	});
}

/**
 * 加载页面全院布局以及数据
 * 
 * @param {}
 *            monitorType搜索类型
 * @param {}
 *            quotaCode指标代码
 * @param {}
 *            totalQuota指标容器
 * @param {}
 *            divId jsp中div
 *            
 *            pageCode 页面唯一标识
 */
function loadHospQuota(monitorType, totalQuota, divId, pageCode) {
	var pageQuotaNodesTemporary = new Array(); //创建一个临时数组
	var str = '';
	var ul = '';
	//循环所有指标
	for (var o in totalQuota) {
		var quotaTypes = totalQuota[o].children;
		if (totalQuota.length > 0) {
			// 拼接ul
			if (o == 0) {
				ul += '<li role="presentation" class="active">';
			} else {
				ul += '<li role="presentation">';
			}
			ul += '<a href="#' + totalQuota[o].code + 'QuaId-hosp' + tabId
					+ '" role="tab" data-toggle="tab" class="top-tab" >'
					+ totalQuota[o].name + '</a>';
			ul += '</li>';
			$('#' + tabId + ' #hosp-ul').html(ul);
			// 开始拼接div
			if (o == 0) {
				str += '<div role="tabpanel" class="tab-pane active" id="'
						+ totalQuota[o].code + 'QuaId-hosp' + tabId + '">';
			} else {
				str += '<div role="tabpanel" class="tab-pane" id="'
						+ totalQuota[o].code + 'QuaId-hosp' + tabId + '">';
			}
			str += '<div class="paddingd10">';
			str += '<div class="row" >';
		}
		for (var o in quotaTypes) {
			var quotas = quotaTypes[o];
			str += ' <div class="col-xs-4"> ';
			str += ' <div class="infocq"> ';
			str += '         <div class="tii margind10'
			if(quotas.name==='产能'){
				str += ' blue-bg"><span><i class="fa fa-users fa-lg"></i>';
			} else if(quotas.name==='效率'){
				str += ' green-bg"><span><i class="fa fa-stethoscope fa-lg"></i>';
			} else if(quotas.name==='安全'){
				str += ' red-bg"><span><i class="fa fa-heartbeat fa-lg"></i>';
			} else {
				str += '"><span>';
			}
			str += quotas.name + '</span></div> ';
			str += ' <div class="ci"> ';
			for (var o1 in quotas.children) {
				var quota = quotas.children[o1];
				var quotaCode = quota.code;
				var quotaName = quota.name;
				var quotaType = quota.type;
				var isLink = quota.islink;
				if(quotaCode=='FeeEffContri'){	
					//费用消耗指数贡献度  汇总时 有当前指标直接跳过  不加载
					continue;
				}
				
				/**
				 * 此处循环加载页面指标，包括渲染页面及加载数据
				 * 加载过的指标 不再加载，直接取到该指标的html代码 追加赋值给str
				 * 没加载过的指标 重新加载
				 * 重新生成页面指标数组---pageQuotaNodesOldObj[pageCode]
				 */
				
				//原来页面显示的指标数组
				var pageQuotaNodesOldTotal = pageQuotaNodesOldObj[pageCode];
				
				if(pageQuotaNodesOldTotal != null && pageQuotaNodesOldTotal.length > 0 && !($.inArray(quotaCode, pageQuotaNodesOldTotal) == -1)){//指标code在原来的页面已经存在
					var quotaOldDiv = $('#' + tabId + ' div[quotaCode="'+quotaCode+'"]').prop("outerHTML");//获取原有的指标页面div
					str += quotaOldDiv;
				}else{
					str += '<div class="row contotalcq2" quotaCode="'+quotaCode+'"> ';
					str += ' <div class="col-xs-6">'
							+ quotaName + '</div> ';
					if("ratio"==quotaType){
						str += '                 <div class="col-xs-6" id="'+quotaCode+'-value">'+getQuotaValue(quotaCode, quotaName, monitorType,isLink, function(value, valuecc, code,name,isLink){
							$("#" + tabId + " #" + divId + " #"+code+"-value").html(comparePercent(value, valuecc));
						})+'</div> ';
					}else{
						str += '<div class="col-xs-6" id="'+quotaCode+'-value">'+getQuotaValue(quotaCode, quotaName, monitorType,isLink, function(value, valuecc, code, name,isLink){
							if(isLink==1){
								var str = compareValue(value, valuecc);//数值比较的字符串
								var reg = /<span class= \"number\".*?>.*?<\/span>/; //正则表达式 匹配 html 中 class = "number" 的span标签
								var num = str.match(reg);//数字串
								if(num==null){
									num = "";
									$("#" + tabId + " #" + divId + " #"+code+"-value").html(str);
								}else{
									num = num[0];
									var symbol = str.replace(reg, "");//符号串
									if(value > 0){
										$("#" + tabId + " #" + divId + " #"+code+"-value").html("<a href=\"javascript:loadCaseDtl('"+name+"','','"+monitorType+"', '"+code+"')\">"+num+"</a>"+symbol);
									} else {
										$("#" + tabId + " #" + divId + " #"+code+"-value").html(num+symbol);
									}
								}
							}else{
								$("#" + tabId + " #" + divId + " #"+code+"-value").html(compareValue(value, valuecc));
							}
						})+'</div> ';
					}
					str += '  </div> ';
				}
				
				/**
				 * 将页面加载的指标code放到临时数组pageQuotaNodesTemporary
				 */
					pageQuotaNodesTemporary.push(quotaCode);
			}
			str += '         </div> ';
			str += '     </div> ';
			str += ' </div> ';
		}
		if (totalQuota.length > 1) {
			str += '</div>';
			str += '</div>';
			str += '</div>';
		}
	}
	//将页面加载的指标code数组添加到对象
	pageQuotaNodesOldObj[pageCode] = pageQuotaNodesTemporary;
	$("#" + tabId + " #" + divId).html(str);//渲染页面及加载数据
}
/**
 * 获取指标值
 * @param {} quotaCode
 * @param {} quotaName
 * @param {} monitorType
 * @param {} isLink
 * @param {} callback
 * @return {String}
 */
function getQuotaValue(quotaCode, quotaName, monitorType,isLink, callback){
	var param=drgUI.setAjaxData(tabId);
	param.monitorType=monitorType;
	param.quotaCode=quotaCode;
	$.post(contextPath + "/DrgsIndexCal/indexCal.dhc", param).done(function(data) {
		if(data.success){
			if(data.data.length>0){
				data = data.data[0];
				callback(data.QuotaValue, data.QuotaValuecc, quotaCode, quotaName,isLink);
			}else{
				callback("", "", quotaCode, quotaName,isLink);
			}
		}else{
			callback("", "", quotaCode, quotaName,isLink);
		}
	});
	return "";
}

/**
 * 拼接各指标的布局以及div
 * 
 * @param {}
 *            totalQuota指标容器
 * @param {}
 *            monitorName 表格第一列表头名称
 * @param {}
 *            divId jsp 中的布局div
 * 
 */
function loadDRGsQuota(totalQuota, monitorName, divId) {
	// 获取调用页面和DIV
	var divIdArr = divId.split("#") ;
	// 调用页面
	var callPageId = null ;
	if( divIdArr.length > 1 ){
		callPageId = divIdArr[0]  ;
		divId = divIdArr[1] ;
	}
	if (!monitorName)
		monitorName = ""
	if (paramTabPage[tabId].compareType == "year") {
		compareName = "同期";
	} else if (paramTabPage[tabId].compareType == "month") {
		compareName = "上期";
	} else if (paramTabPage[tabId].compareType == "manage") {
		compareName = "绩效";
	} else if (paramTabPage[tabId].compareType == "std") {
		compareName = "标杆";
	}
	else if (paramTabPage[tabId].compareType == "morestd") {
		compareName = "标杆";
	}
	var str = '';
	var ul = '';

	for (var o in totalQuota) {
		var QuotaCode = totalQuota[o].children;
		// 拼接ul
		if (totalQuota.length > 0) {
			if (o == 0) {
				ul += '<li role="presentation" class="active">';
			} else {
				ul += '<li role="presentation">';
			}
			ul += '<a href="#' + totalQuota[o].code + 'QuaId' + tabId
					+ '" role="tab" data-toggle="tab" class="top-tab">'
					+ totalQuota[o].name + '</a>';
			ul += '</li>';
			$('#' + tabId + ' #depgroup-ul').html(ul);
		}
		// 开始拼接div
		if (o == 0) {
			str += '<div role="tabpanel" class="tab-pane active" id="'
					+ totalQuota[o].code + 'QuaId' + tabId + '">';
		} else {
			str += '<div role="tabpanel" class="tab-pane" id="'
					+ totalQuota[o].code + 'QuaId' + tabId + '">';
		}

		for (var o in QuotaCode) {
			var quotas = QuotaCode[o];
			str += ' <div class="paddingd10"> ';
			str += '   <div class="tabconti';
			if(quotas.name==='产能'){
				str += ' blue-bg"><i class="fa fa-users fa-lg"></i>';
			} else if(quotas.name==='效率'){
				str += ' green-bg"><i class="fa fa-stethoscope fa-lg"></i>';
			} else if(quotas.name==='安全'){
				str += ' red-bg"><i class="fa fa-heartbeat fa-lg"></i>';
			} else {
				str += '">';
			}
			str += quotas.name + '</div> ';
			str += '   <ul class="nav nav-tabs tabconulcq" role="tablist"> ';
			for (var o1 in quotas.children) {
				var quota = quotas.children[o1];
				var quotaCode = quota.code;
				var quotaName = quota.name;
				if (o1 == 0) {
					str += '       <li role="presentation" class="active"> ';
				} else {
					str += '       <li role="presentation"> ';
				}
				str += '           <a href="#' + quotaCode + '-tc' + tabId
						+ '" role="tab" data-toggle="tab">' + quotaName
						+ '</a> ';
				str += '       </li> ';
			}
			str += '   </ul> ';
			str += '   <div class="clearfix"></div> ';
			str += '   <div class="tab-content"> ';
			for (var o1 in quotas.children) {
				var quota = quotas.children[o1];
				var quotaCode = quota.code;
				var quotaName = quota.name;
				if (o1 == 0) {
					str += '       <div role="tabpanel" class="tab-pane active" compareName="'
							+ compareName
							+ '" monitorName="'
							+ monitorName
							+ '" quotaName="'
							+ quotaName
							+ '" quotaCode="'
							+ quotaCode
							+ '" id="'
							+ quotaCode
							+ '-tc'
							+ tabId
							+ '"> ';
				} else {
					str += '       <div role="tabpanel" class="tab-pane" compareName="'
							+ compareName
							+ '" monitorName="'
							+ monitorName
							+ '" quotaName="'
							+ quotaName
							+ '" quotaCode="'
							+ quotaCode
							+ '" id="'
							+ quotaCode
							+ '-tc'
							+ tabId
							+ '"> ';
				}
				str += '           <div class="row padding100"> ';
				str += '               <div class="col-xs-5"> ';
				str += '                   <div class="echartscq" style="width:475px;"></div> ';
				str += '               </div> ';
				str += '               <div class="col-xs-7 dataChangeSel"> ';
				str += '                   <table id="'
						+ quotaCode
						+ '-table'
						+ tabId
						+ '" class="table table-striped" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
				str += '                       <caption class="contaotalsccq">'
						+ monitorName + quotas.name + '(' + quotaName
						+ ')</caption> ';
				str += '                       <thead> ';
				str += '                           <tr role="row"> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1" aria-sort="ascending">'
						+ monitorName + '</th> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">本期值</th> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'
						+ compareName + '值</th> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">增长率</th> ';
				if(callPageId == "depToDRGs"){
					str += '                           <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">是否应治疗</th> ';
				}
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">操作</th> ';
				str += '                           </tr> ';
				str += '                       </thead> ';
				str += '                       <tbody></tbody> ';
				str += '                   </table> ';
				str += '               </div> ';
				str += '           </div> ';
				str += '       </div> ';
			}
			str += '   </div> ';
			str += ' </div> ';
		}
		str += '</div>';

	}
	$("#" + tabId + " #" + divId).html(str);
}

/**
 * 为页面下半部分指标加载数据以及图标
 * @param {} totalQuota 可配置指标组
 * @param {} monitorType 获取数据类型
 * @param {} across 是否交叉
 */
function loadDRGsQuotaData(totalQuota,monitorType,across,customCol,pageCode){
	for (var o in totalQuota) {
		var quotaTypes = totalQuota[o].children;
		for (var o in quotaTypes) {
			var quotas = quotaTypes[o];
			for (var o1 in quotas.children) {
				var quota = quotas.children[o1];
				var quotaCode = quota.code;
				var quotaName = quota.name;
				var quotaType = quota.type;
				var isLink = quota.islink;
				// 自定义列数据
				var unsortc = 4;
				if(!(customCol==null||customCol==""||typeof(customCol)=="undefined")&&customCol.func!=undefined) {
					unsortc = 5;
				}
				/**
				 * 此处循环加载页面指标数据
				 * 加载过的指标 不再加载，直接取到该指标历史页面加载数据
				 * 没加载过的指标 重新加载
				 * 
				 */
				if(pageQuotaNodesOldObj != null && pageQuotaNodesOldObj.hasOwnProperty(pageCode+"-"+quotaCode)){//指标code在原来的页面已经存在
					var quotaData = pageQuotaNodesOldObj[pageCode+"-"+quotaCode];//获取原有页面加载的指标数据
					var quotaColumns = pageQuotaNodesOldObj[pageCode+"-"+quotaCode+"-columns"];//获取原有页面加载datatable属性
					var paramsDataTables={order:[],columnDefs:[{"orderable": false,"targets":[unsortc] }]};
					$("#"+quotaCode+"-table"+tabId).drgsDataTable(quotaColumns, quotaData, paramsDataTables);
					
				}else{//重新加载
					loadDRGsQuotaDatasub(quotaCode, quotaType, quotaName, monitorType,across,customCol,pageCode,isLink);// 重新请求加载指标数据
				}
			}
		}
	}
}
/**
 * 
 * @ Discription:加载数据回调
 * @Autor ：liuhongjun
 * @param quotaCode指标代码
 * @param quotaType指标类型
 * @param quotaName指标名
 * @param monitorType分析对象
 * @param across
 * @param customCol
 * @param pageCode
 * @param isLink 是否有连接
 * @returns
 * any
 * ywcCommon.js
 * 2017年6月18日下午6:31:40
 */

function loadDRGsQuotaDatasub(quotaCode, quotaType, quotaName, monitorType,across,customCol,pageCode,isLink) {
	var param=drgUI.setAjaxData(tabId);
	param.monitorType=monitorType;
	param.quotaCode=quotaCode;	
	$.post(contextPath + "/DrgsIndexCal/indexCal.dhc",param).done(function(data) {
		data = data.data;
		//将页面加载的指标code数组添加到对象
		 pageQuotaNodesOldObj[pageCode+"-"+quotaCode] = data;
			var hasCaseDtl = isLink==1?true:false;
			var columns = [
			               {  "data": "ccode1",
			            	  "createdCell": function (nTd, sData, oData, iRow, iCol) {
								  $(nTd).attr('limit', 24);
								  $(nTd).limit();
							   },
			            	   "render": function(obj, type, full) {
			               			if(full.ccode==null||full.ccode=="null"){
			               				return "未入组";
		               				}else if(monitorType=="mdc"||monitorType=="adrg"){//病组线   mdc或adrg
		               					if(full.ccode=="notcode"){
		               						return "未入组";
		               					}
			               				return "<a title ='' href=\"javascript:toNextLayerYiZheng("+across+",'" + monitorType + "','"+ full.ccode + "','" + full.ddesc+ "') \">" +full.ccode+"-"+full.ddesc + "</a>";
		               				}else if(monitorType=="drgs"){
		               					if(full.ccode=="notcode"){
		               						return "未入组";
		               					}
			               				return full.ccode+"-"+full.ddesc;
		               				}else{
			               				if (toNextLayerBool(monitorType)) {
			               					return "<a title ='' href=\"javascript:toNextLayerYiZheng("+across+",'" + monitorType + "','"+ full.ccode + "','" + full.ddesc+ "') \">" + full.ddesc + "</a>";
			               				} else {	
			               					return full.ddesc;
		               					}
		               				}
			            	   }
			               },
			               { "data": "QuotaValue_1", 
			            	   "type":"number-html",
			            	   "render": function(obj, type, full){
			            		   full.QuotaValue=full.QuotaValue!=null?full.QuotaValue:'';//强制转换
			            		   full.QuotaValuecc=full.QuotaValuecc!=null?full.QuotaValuecc:'';
		            			   if(hasCaseDtl && full.QuotaValue>0){
										return "<a href=\"javascript:loadCaseDtl('"+full.ddesc+"|"+quotaName+"','"+full.ccode+"','"+monitorType+"', '"+quotaCode+"')\">"+formatNumber(full.QuotaValue)+"</a>"
		            			   }
		            			   return "<span>"+formatNumber(full.QuotaValue)+"</span>";
			            	   }
			               },
			               {"data": "QuotaValuecc_1", "type":"numeric-comma",
			            	   "render": function(obj, type, full){
		            			   return formatNumber(full["QuotaValuecc"]);
			            	   }
			               },
			               { "data": "increasing","type": "number-fate",
			            	   "render":function(obj, type, full){
			            		   if("ratio"==quotaType){
			            			   return gridcompareValuePercent(full.QuotaValue, full["QuotaValuecc"]);
			            		   }
			            		   return gridcompareValue(full.QuotaValue, full["QuotaValuecc"]);
			            	   }
			               },         
			               { "data": "OPERATION",
			            	   "render":function(obj, type, full){
			            		   if(across)
		               				{//交叉的情况	科室线下各病种层次	病区线下各科室层次
			            			   if(full.ccode==null){
			            				   var operation = "";
			            				   if(monitorType == "drgs"&&(param.previous.match("depGroup|dep|ward")))
		            					   {
			            					   operation = "<a href=\"javascript:alertData()\" class='jumplink'><i class='fa fa-hospital-o'></i></a>&nbsp;&nbsp;";
		            					   }
		            					   return operation
		            					   + "<a title='入组病例' class='jumplink' href=\"javascript:alertData()\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"								
		            					   + "<a title='趋势' href=\"javascript:alertData()\" class='trend-link'><i class='fa fa-line-chart'></i></a>";
	            					   } else{
		            					   var operation = "";
		            					   if(monitorType == "drgs"&&(param.previous.match("depGroup|dep|ward"))) {
		            						   operation = "<a title='科室' href=\"javascript:ywcDrgToDepLine('"+ full.ccode+ "', '"+ full.ddesc+ "')\" class='jumplink'><i class='fa fa-hospital-o'></i></a>&nbsp;&nbsp;";
	            						   }
		            					   return  operation
		            					   + "<a title='入组病例' class='jumplink' href=\"javascript:loadDetail('"+ full.ccode+ "','"+ full.ddesc+ "','"+ monitorType+ "')\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"								
		            					   + "<a title='趋势' href=\"javascript:trend('"+full.ccode+"', '"+full.ddesc+"', '"+monitorType+"', '"+quotaCode+"', '"+quotaName+"')\" class='trend-link'><i class='fa fa-line-chart'></i></a>";
	            					   }
		               				}else{
			               				if(monitorType=="mdc"||monitorType=="adrg"||monitorType=="drgs"){
			               					if(full.ccode==null||full.ccode=="notcode"){
			               						return "<span><i class='fa fa-hospital-o'></i></span>&nbsp;"
			               						+ "<a title='入组病例' class='jumplink' href=\"javascript:alertData()\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"
			               						+ "<a title='趋势' href=\"javascript:trend('未入组', '未入组', '"+monitorType+"', '"+quotaCode+"', '"+quotaName+"')\" class='trend-link'><i class='fa fa-line-chart'></i></a>";
		               						}else{
			               						return "<a title='科室' href=\"javascript:ywcDisToDep('"+ full.ccode+ "', '"+ full.ddesc+ "', '"+ monitorType+ "')\" class='jumplink'><i class='fa fa-hospital-o'></i></a>&nbsp;&nbsp;"								
			               						+ "<a title='入组病例' href=\"javascript:loadDetail('"+ full.ccode+ "', '"+ full.ddesc+ "', '"+ monitorType+ "')\" class='jumplink'><i class='fa fa-users'></i></a>&nbsp;&nbsp;"
			               						+ "<a title='趋势' href=\"javascript:trend('"+full.ccode+"', '"+full.ddesc+"', '"+monitorType+"', '"+quotaCode+"', '"+quotaName+"')\" class='trend-link'><i class='fa fa-line-chart'></i></a>";
		               						}
			               				}else if(monitorType=="depGroup"||monitorType=="dep"||monitorType=="ward"||monitorType=="clinic"){
			               					var operation = "";
											if (typeof (param.disBack) == "undefined") {
												if (full.ccode == null) {
													operation = "<span href=\"javascript:alertData()\"><i class='fa fa-list-alt'></i></span>&nbsp;";
												} else {
													operation = "<a title='病组' class='jumplink' href=\"javascript:loadDRGs('"+ full.ccode+ "','"+ full.ddesc+ "','"+ monitorType+ "')\"><i class='fa fa-list-alt'></i></a>&nbsp;&nbsp;";
												}
											}
			               					if(full.ccode==null){
			               						return operation
			               						+ "<a title='入组病例' class='jumplink' href=\"javascript:alertData()\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"
			               						+ "<a title='趋势' class='trend-link' href=\"javascript:alertData()\"><i class='fa fa-line-chart'></i></a>" ;
		               						}else{
			               						return operation
			               						+ "<a title='入组病例' href=\"javascript:loadDetail('"+ full.ccode+ "', '"+ full.ddesc+ "', '"+ monitorType+ "')\" class='jumplink'><i class='fa fa-users'></i></a>&nbsp;&nbsp;"
			               						+ "<a title='趋势' href=\"javascript:trend('"+full.ccode+"', '"+full.ddesc+"', '"+monitorType+"', '"+quotaCode+"', '"+quotaName+"')\" class='trend-link'><i class='fa fa-line-chart'></i></a>" ;
		               						}
			               				}
		               				}
		            		   }
			               }];
			// 自定义列数据
			var unsortc = 4;
			if(!(customCol==null||customCol==""||typeof(customCol)=="undefined")&&customCol.func!=undefined){
				isTreatment(data) ;
				customCol.func(columns) ;
				unsortc = 5;
			}
			
			
			//将页面加载的指标code数组添加到对象
			pageQuotaNodesOldObj[pageCode+"-"+quotaCode+"-columns"] = columns;
			var paramsDataTables={order:[],columnDefs:[{"orderable": false,"targets":[unsortc] }]};
			$("#"+quotaCode+"-table"+tabId).drgsDataTable(columns, data, paramsDataTables);
	});
}

/**
 * 判断是否有下一层
 * @param monitorType 取值 depGroup dep ward clinic
 * @returns {Boolean}
 */
function toNextLayerBool(monitorType){
	var bool = false;
	switch(monitorType){
	case "depGroup":
		if(commonLayerConfig.length>=4&&(commonLayerConfig[1]=='1'||commonLayerConfig[2]=='1')){
		  bool = true;
		}
		break;
	case "dep":
		if(commonLayerConfig.length>=4&&(commonLayerConfig[2]=='1'||commonLayerConfig[3]=='1')){
		bool = true;
		}
		break;
	case "ward":
		if(commonLayerConfig.length>=4&&commonLayerConfig[3]=='1'){
		bool = true;
		}
		break;
	case "mdc":
		bool = true;
		break;
	case "adrg":
		bool = true;
		break;
	}
	return bool;	
}

/**
 * 跳往下一个层级
 * across 标识是否交叉
 * monitorType 页面所处的层次 depGroup dep ward clinic
 * code某一层级的代码
 * name某一层级的名称
 */
function toNextLayerYiZheng(across,monitorType,code,desc){
	var param = jQuery.extend(true,{},paramTabPage[tabId]);//参数
	param.previous = monitorType;//指示当前的层次
	var destUrl = "";
	var pageId = "";
	var disBack = "";
	if(typeof(param.disBack)!="undefined"){
		disBack = "1";
	}
	switch(monitorType){
	case "depGroup":
		param.depGroupCode = code;
		param.depGroupName = desc;
		if(commonLayerConfig.length>=4){
			if(commonLayerConfig[1]=='1'){
				if(across){//病种线下的科室组跳往科室
					destUrl = "/pages/yizheng/ywcDisLineDep.jsp";
					pageId = code+"yizheng_DepGroup_To_DisLineDep";
				}else{//科室线科室组跳往科室
					destUrl = "/pages/yizheng/ywcDep.jsp";
					pageId = code+disBack+"yizheng_DepGroup_To_Dep";
				}
			}else if(commonLayerConfig[2]=='1'){
				if(across){//病种线下的科室组跳往病区
					destUrl = "/pages/yizheng/ywcDisLineWard.jsp";
					pageId = code+"yizheng_DepGroup_To_DisLineWard";
				}else{//科室线科室组跳往病区
					destUrl = "/pages/yizheng/ywcWard.jsp";
					pageId = code+disBack+"yizheng_DepGroup_To_Ward";
				}
			}
		}
		break;
	case "dep":
		param.depCode = code;
		param.depName = desc;
		if(commonLayerConfig.length>=4){
			if(commonLayerConfig[2]=='1'){
				if(across){//病种线下的科室组跳往病区
					destUrl = "/pages/yizheng/ywcDisLineWard.jsp";
					pageId = code+"yizheng_Dep_To_DisLineWard";
				}else{//科室线科室组跳往病区
					destUrl = "/pages/yizheng/ywcWard.jsp";
					pageId = code+disBack+"yizheng_Dep_To_Ward";
				}
			}else if(commonLayerConfig[3]=='1'){
				if(across){//病种线下的科室跳往主诊组
					destUrl = "/pages/yizheng/ywcDisLineClinic.jsp";
					pageId = code+"yizheng_Dep_To_DisLineClinic";
				}else{//科室线科室跳往主诊组
					destUrl = "/pages/yizheng/ywcClinic.jsp";
					pageId = code+disBack+"yizheng_Dep_To_Clinic";
				}
			}
		}
		break;
	case "ward":
		param.wardCode = code;
		param.wardName = desc;
		if(commonLayerConfig.length>=4){
			if(commonLayerConfig[3]=='1'){
				if(across){//病种线下的科室跳往主诊组
					destUrl = "/pages/yizheng/ywcDisLineClinic.jsp";
					pageId = code+"yizheng_Ward_To_DisLineClinic";
				}else{//科室线科室跳往主诊组
					destUrl = "/pages/yizheng/ywcClinic.jsp";
					pageId = code+disBack+"yizheng_Ward_To_Clinic";
				}
			}
		}
		break;
	case "mdc":
		param.mdcCode = code;
		param.mdcName = desc;
		if(across){//科室线下的MDC跳往ADRG
			destUrl = "/pages/yizheng/ywcDepLineAdrg.jsp";
			pageId = code+"yizheng_Mdc_To_DepLineAdrg";
		}else{//病种线MDC跳往ADRG
			destUrl = "/pages/yizheng/ywcMdcAdrg.jsp";
			pageId = code+"yizheng_Mdc_To_Adrg";
		}
		break;
	case "adrg":
		param.adrgCode = code;
		param.adrgName = desc;
		if(across){//科室线下的ADRG跳往DRG
			destUrl = "/pages/yizheng/ywcDepLineDrg.jsp";
			pageId = code+"yizheng_Adrg_To_DepLineDrg";
		}else{//病种线ADRG跳往DRG
			destUrl = "/pages/yizheng/ywcMdcDrgs.jsp";
			pageId = code+"yizheng_Adrg_To_Drg";
		}
		break;
	}
	if(destUrl!=""){
		openTab(destUrl, desc+"|"+"指标监测",pageId, pageId,param);
	}	
}

function loadDRGs(code, desc, type) {
	var param = jQuery.extend(true, {}, paramTabPage[tabId]);
	param.code = code;
	param.desc = desc;
	param.type = type;
	param.monitorType = type;
	param.previous = type;
	if(desc == null || desc=="null"){
		desc="其他";
	}
	if(type == "depGroup"){
		param.depGroupName = desc;
		param.depGroupCode = code;
	}else if(type == "dep"){
		param.title = "科室指标";
		param.depCode = code;
		param.depName = desc;
	}else if(type == "ward"){
		param.title = "病区指标";
		param.wardCode = code;
		param.wardName = desc;
	}else if(type == "clinic"){
		param.clinic_desc = desc;
		param.groupName = code;
	}else if(type == "protomedicus"){
		param.protomedicus_desc = desc;
		param.protomedicus = code;
	}else if(type == "physician"){
		param.physician_desc = desc;
		param.physician = code;
	}else if(type == "resident"){
		param.resident_desc = desc;
		param.resident = code;
	}
	openTab('/pages/yizheng/ywcDepLineDrg.jsp', desc + "|" + 'DRG', type + 'DRG'+ code, type + 'DRG' + code, param);
}

function loadUpperStore(monitorType) {
	var code = paramTabPage[tabId].code;
	var desc = paramTabPage[tabId].desc;
	var type = paramTabPage[tabId].type;
	if(monitorType == "drgs"){
		openTab('/pages/yizheng/ywcDepLineAdrg.jsp',desc+"|"+"ADRG",type+'ADRG'+code,type+'ADRG'+code,paramTabPage[tabId]);
	}else if(monitorType == "adrg"){
		openTab('/pages/yizheng/ywcDepLineMdc.jsp',desc+"|"+"MDC",type+'MDC'+code,type+'MDC'+code,paramTabPage[tabId]);
	}
	else if(monitorType == "dep"){
		openTab('/pages/yizheng/ywcDisLineDepGroup.jsp',code+desc+"|"+"科室组",type+'depGroupYwcBack'+code,type+'depGroupYwcBack'+code,paramTabPage[tabId]);
	}
}
/**
 * 医政角色病种线 跳往科室线
 * @param code 病种层代码
 * @param desc 病种层描述
 * @param type 监测类型
 */
function ywcDisToDep(code, desc, type){
	var param = jQuery.extend(true, {}, paramTabPage[tabId]);
	param.code = code;
	param.desc = desc;
	param.type = type;
	param.monitorType = type;
	param.previous = type; 
	var destUrl = ""; 
	var depLayerName = "";
	var depLayer = "";
	if(commonLayerConfig[1]=="1"){
		destUrl = "/pages/yizheng/ywcDisLineDep.jsp";
		depLayerName = "科室";
		depLayer = "dep";
	}else if(commonLayerConfig[2]=="1"){
		destUrl = "/pages/yizheng/ywcDisLineWard.jsp";
		depLayerName = "病区";
		depLayer = "ward";
	}
	
	var disLineToDepTitle ="";
	var disLineToDepPageId ="";
	switch(type){
	case "mdc":
		param.mdcCode = code;
		param.mdcDesc = desc;
		param.title = "MDC指标";
		disLineToDepTitle = param.mdcCode+param.mdcDesc+"|"+depLayerName;
		disLineToDepPageId = "yizheng"+"-"+"mdc"+"-"+param.mdcCode+"-"+depLayer;
		break;
	case "adrg":
		param.title = "ADRG指标";
		param.adrgCode = code;
		param.adrgDesc = desc;
		disLineToDepTitle = param.adrgCode+param.adrgDesc+"|"+depLayerName;
		disLineToDepPageId = "yizheng"+"-"+"adrg"+"-"+param.adrgCode+"-"+depLayer;
		break;
	case "drgs":
		param.title = "DRG指标";
		param.drgCode = code;
		param.drgDesc = desc;
		disLineToDepTitle = param.drgCode+param.drgDesc+"|"+depLayerName;
		disLineToDepPageId = "yizheng"+"-"+"drg"+"-"+param.drgCode+"-"+depLayer;
		break;
	}
	openTab(destUrl,disLineToDepTitle,disLineToDepPageId,disLineToDepPageId,param);

}
/**
 * 
 * @ Discription:DRG层级下钻科室线层级
 * @Autor ：mazhaoyan
 * @param code
 * @param desc
 * @param type
 * void
 * ywcCommon.js
 * 2018年2月9日上午11:40:46
 */
function ywcDrgToDepLine(code, desc){
	var destUrl = ""; 
	var pageId = "";
	var param = jQuery.extend(true, {}, paramTabPage[tabId]);
	param.drgCode = code;
	param.disBack = "1";
	var previous = param.previous;
	switch(previous){
	case "depGroup":
		if(commonLayerConfig[1]=="1"){
			destUrl = "/pages/yizheng/ywcDep.jsp";
			pageId = code+"yizheng_drg_Dg_To_Dep";
		}else if(commonLayerConfig[2]=="1"){
			destUrl = "/pages/yizheng/ywcWard.jsp";
			pageId = code+"yizheng_drg_Dg_To_ward";
		}
		break;
	case "dep":
		if(commonLayerConfig[2]=="1"){
			destUrl = "/pages/yizheng/ywcWard.jsp";
			pageId = code+"yizheng_drg_Dep_To_Ward";
		}else if(commonLayerConfig[3]=="1"){
			destUrl = "/pages/yizheng/ywcClinic.jsp";
			pageId = code+"yizheng_drg_Dep_To_clinic";
		}
		break;
	case "ward":
		if(commonLayerConfig[3]=="1"){
			destUrl = "/pages/yizheng/ywcClinic.jsp";
			pageId = code+"yizheng_drg_Ward_To_Clinic";
		}
		break;
	}
	openTab(destUrl, desc+"|"+"指标监测",pageId, pageId,param);
}


/**
 * 所有病例图标按钮 获取病例明细
 * @param code
 * @param desc
 * @param type
 * @returns
 */
function loadDetail(code, desc, type) {
	var param = jQuery.extend(true, {}, paramTabPage[tabId]);
	param.caseLinkCode = "InCaseCnt";//所有病例图标按钮 均获取入组病例数
	if (type == "drgs") {
		param.drgCode = code;
		if(desc == null || desc=="null"|| desc=="未维护编码"){
			desc="未入组";
		}
	}else if (type == "adrg") {
		param.adrgCode = code;
		if(desc == null || desc=="null"|| desc=="未维护编码"){
			desc="未入组";
		}
	}else if (type == "mdc") {
		param.mdcCode = code;
		if(desc == null || desc=="null"|| desc=="未维护编码"){
			desc="未入组";
		}
	}else if (type == "depGroup") {
		param.depGroupCode = code;
		if(desc == null || desc=="null"){
			desc="其他组";
		}
	}else if (type == "dep") {
		param.depCode = code;
		if(desc == null || desc=="null"){
			desc="其他组";
		}
	}else if (type == "ward") {
		param.wardCode = code;
		if(desc == null || desc=="null"){
			desc="其他组";
		}
	}else if (type == "clinic") {//主诊医师
		param.groupName = code;
		if(desc == null || desc=="null"){
			desc="其他组";
		}
	}else if (type == "protomedicus") {
		//主任医师
		param.protomedicus = code;
		if(desc == null || desc=="null"){
			desc="其他组";
		}
	}else if (type == "physician") {
		//主治医师
		param.physician = code;
		if(desc == null || desc=="null"){
			desc="其他组";
		}
	}else if (type == "resident") {
		//住院医师
		param.resident = code;
		if(desc == null || desc=="null"){
			desc="其他组";
		}
	}
	openTab('/pages/drgscommon/case.jsp', desc +"|"+ '病例明细', type + code + 'Case', type + code + 'Case', param);
}

//提示未入组数据
function alertData(){
	drgUI.warning('未入组数据');
	return;
}
/**
 * 
 * @ Discription:病例明细
 * @Autor ：liuhongjun
 * @param title
 * @param ccode
 * @param monitorType
 * @param quotaCode
 * @returns
 * any
 * ywcCommon.js
 * 2017年6月18日下午6:51:37
 */
function loadCaseDtl(title, ccode, monitorType, quotaCode){
	var param = jQuery.extend(true, {}, paramTabPage[tabId]);
	param.caseLinkCode = quotaCode;
	if(ccode){
		if(monitorType == "depGroup"){
			param.depGroupCode=ccode;
		}else if(monitorType == "dep"){
			param.depCode=ccode;
		}else if(monitorType == "ward"){
			param.wardCode=ccode;
		}else if(monitorType == "clinic"){
			param.groupName=ccode;
		}else if(monitorType == "protomedicus"){
			param.protomedicus=ccode;
		}else if(monitorType == "physician"){
			param.physician=ccode;
		}else if(monitorType == "resident"){
			param.resident=ccode;
		}else if(monitorType == "mdc"){
			param.mdcCode=ccode;
		}else if(monitorType == "adrg"){
			param.adrgCode=ccode;
		}else if(monitorType == "drgs"){
			param.drgCode=ccode;
		}
		openTab('/pages/drgscommon/case.jsp', title+"|"+"病例明细", "caseDtl"+monitorType+ccode+quotaCode, "caseDtl"+monitorType+ccode+quotaCode, param);
	}else{
		ccode="hosp"
		openTab('/pages/drgscommon/case.jsp', title+"|"+"病例明细", "caseDtl"+monitorType+ccode+quotaCode, "caseDtl"+monitorType+ccode+quotaCode, param);
	}
}
//医生层面的div 结构拼装
function loadYiZhengDoctorDiv(totalQuota,divId){
	var doctorul = '';
	var doctorStr = '';
	if (doctorSetConfig.length > 0) {
		if(doctorSetConfig[0]==1){
			var data = docTabDiv(totalQuota,'主任医师', 'protomedicus');
			var str = data[0];
			var ul = data[1];
			doctorul += '<li role="presentation">';
			doctorul += '	<a href="#protomedicus' + tabId + '" role="tab" data-toggle="tab" class="top-tab">主任医师</a>';
			doctorul += '</li>';
			doctorStr += '<div role="tabpanel" class="tab-pane" id="protomedicus' + tabId + '">';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<ul class="nav nav-tabs tabconulcq" role="tablist">'+ul+'</ul>';
			doctorStr += '	<div class="clearfix"></div>';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<div id="quotasId_protomedicus" class="tab-content">'+str+'</div>';
			doctorStr += '</div>';
		}if(doctorSetConfig[1]==1){
			var data = docTabDiv(totalQuota,'主诊医师' , 'clinic');
			var str = data[0];
			var ul = data[1];
			doctorul += '<li role="presentation">';
			doctorul += '	<a href="#clinic' + tabId + '" role="tab" data-toggle="tab" class="top-tab">主诊医师</a>';
			doctorul += '</li>';
			doctorStr += '<div role="tabpanel" class="tab-pane" id="clinic' + tabId + '">';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<ul class="nav nav-tabs tabconulcq" role="tablist">'+ul+'</ul>';
			doctorStr += '	<div class="clearfix"></div>';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<div id="quotasId_clinic" class="tab-content">'+str+'</div>';
			doctorStr += '</div>';
		}
		if(doctorSetConfig[2]==1){	
			var data = docTabDiv(totalQuota, '住院医师', 'resident');
			var str = data[0];
			var ul = data[1];
			doctorul += '<li role="presentation">';
			doctorul += '	<a href="#resident' + tabId + '" role="tab" data-toggle="tab" class="top-tab">住院医师</a>';
			doctorul += '</li>';
			doctorStr += '<div role="tabpanel" class="tab-pane" id="resident' + tabId + '">';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<ul class="nav nav-tabs tabconulcq" role="tablist">'+ul+'</ul>';
			doctorStr += '	<div class="clearfix"></div>';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<div id="quotasId_resident" class="tab-content">'+str+'</div>';
			doctorStr += '</div>';		
		}
		if(doctorSetConfig[3]==1){
			var data = docTabDiv(totalQuota, '主治医师', 'physician');
			var str = data[0];
			var ul = data[1];
			doctorul += '<li role="presentation">';
			doctorul += '	<a href="#physician' + tabId + '" role="tab" data-toggle="tab" class="top-tab">主治医师</a>';
			doctorul += '</li>';
			doctorStr += '<div role="tabpanel" class="tab-pane" id="physician' + tabId + '">';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<ul class="nav nav-tabs tabconulcq" role="tablist">'+ul+'</ul>';
			doctorStr += '	<div class="clearfix"></div>';
			doctorStr += '	<div class="paddingd10"></div>';
			doctorStr += '	<div id="quotasId_physician" class="tab-content">'+str+'</div>';
			doctorStr += '</div>';
		}
		$('#' + tabId + ' #depgroup-ul').html(doctorul);
		$('#' + tabId + ' #'+divId).html(doctorStr);
		
		$('#' + tabId + ' #depgroup-ul li:eq(0)').addClass("active");
		$('#' + tabId + ' #'+divId+'>.tab-pane:eq(0)').addClass("active");
		
	}
}

function docTabDiv(totalQuota, monitorName, doctor){
	if (paramTabPage[tabId].compareType == "year") {
		compareName = "同期";
	} else if (paramTabPage[tabId].compareType == "month") {
		compareName = "上期";
	} else if (paramTabPage[tabId].compareType == "manage") {
		compareName = "绩效";
	} else if (paramTabPage[tabId].compareType == "std") {
		compareName = "标杆";
	}
	else if (paramTabPage[tabId].compareType == "morestd") {
		compareName = "标杆";
	}
	var str = '';
	var ul = '';
	for (var o in totalQuota) {
		var QuotaCode = totalQuota[o].children;
		// 拼接ul
		if (totalQuota.length > 0) {
			if (o == 0) {
				ul += '<li role="presentation" class="active">';
			} else {
				ul += '<li role="presentation">';
			}
			ul += '<a href="#' + totalQuota[o].code + 'QuaId' + tabId + doctor
					+ '" role="tab" data-toggle="tab" class="top-tab">'
					+ totalQuota[o].name + '</a>';
			ul += '</li>';
		}
		// 开始拼接div
		if (o == 0) {
			str += '<div role="tabpanel" class="tab-pane active" id="'
					+ totalQuota[o].code + 'QuaId' + tabId + doctor + '">';
		} else {
			str += '<div role="tabpanel" class="tab-pane" id="'
					+ totalQuota[o].code + 'QuaId' + tabId + doctor + '">';
		}

		for (var o in QuotaCode) {
			var quotas = QuotaCode[o];
			str += ' <div class="paddingd10"> ';
			str += '   <div class="tabconti';
			if(quotas.name==='产能'){
				str += ' blue-bg"><i class="fa fa-users fa-lg"></i>';
			} else if(quotas.name==='效率'){
				str += ' green-bg"><i class="fa fa-stethoscope fa-lg"></i>';
			} else if(quotas.name==='安全'){
				str += ' red-bg"><i class="fa fa-heartbeat fa-lg"></i>';
			} else {
				str += '">';
			}
			str += quotas.name + '</div> ';
			str += '   <ul class="nav nav-tabs tabconulcq" role="tablist"> ';
			for (var o1 in quotas.children) {
				var quota = quotas.children[o1];
				var quotaCode = quota.code;
				var quotaName = quota.name;
				if (o1 == 0) {
					str += '       <li role="presentation" class="active"> ';
				} else {
					str += '       <li role="presentation"> ';
				}
				str += '           <a href="#' + quotaCode + '-tc' + tabId + doctor 
						+ '" role="tab" data-toggle="tab">' + quotaName
						+ '</a> ';
				str += '       </li> ';
			}
			str += '   </ul> ';
			str += '   <div class="clearfix"></div> ';
			str += '   <div class="tab-content"> ';
			for (var o1 in quotas.children) {
				var quota = quotas.children[o1];
				var quotaCode = quota.code;
				var quotaName = quota.name;
				if (o1 == 0) {
					str += '       <div role="tabpanel" class="tab-pane active" compareName="'
							+ compareName
							+ '" monitorName="'
							+ monitorName
							+ '" quotaName="'
							+ quotaName
							+ '" quotaCode="'
							+ quotaCode
							+ '" id="'
							+ quotaCode
							+ '-tc'
							+ tabId
							+ doctor 
							+ '"> ';
				} else {
					str += '       <div role="tabpanel" class="tab-pane" compareName="'
							+ compareName
							+ '" monitorName="'
							+ monitorName
							+ '" quotaName="'
							+ quotaName
							+ '" quotaCode="'
							+ quotaCode
							+ '" id="'
							+ quotaCode
							+ '-tc'
							+ tabId
							+ doctor 
							+ '"> ';
				}
				str += '           <div class="row padding100"> ';
				str += '               <div class="col-xs-5"> ';
				str += '                   <div class="echartscq" style="width:475px;"></div> ';
				str += '               </div> ';
				str += '               <div class="col-xs-7 dataChangeSel"> ';
				str += '                   <table id="'
						+ quotaCode
						+ '-table'
						+ tabId
						+ doctor 
						+ '" class="table table-striped" cellspacing="0" width="100%" role="grid" aria-describedby="example_info"> ';
				str += '                       <caption class="contaotalsccq">'
						+ monitorName + quotas.name + '(' + quotaName
						+ ')</caption> ';
				str += '                       <thead> ';
				str += '                           <tr role="row"> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1" aria-sort="ascending">'
						+ monitorName + '</th> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">本期值</th> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">'
						+ compareName + '值</th> ';
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">增长率</th> ';
				/*if(callPageId == "depToDRGs"){
					str += '                           <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">是否应治疗</th> ';
				}*/
				str += '                               <th tabindex="0" aria-controls="example" rowspan="1" colspan="1">操作</th> ';
				str += '                           </tr> ';
				str += '                       </thead> ';
				str += '                       <tbody></tbody> ';
				str += '                   </table> ';
				str += '               </div> ';
				str += '           </div> ';
				str += '       </div> ';
			}
			str += '   </div> ';
			str += ' </div> ';
		}
		str += '</div>';

	}
	var data = [];
	data.push(str);
	data.push(ul);
	return data;
}


/**
 * 
 * @param totalQuota
 * @param monitorType
 * @param functionName
 * @param depLayer 当前所处科室线的层次   科室组1 科室2 病区3 主诊组4
 * @param customColumn 自定义列，包括该列请求的指标和 列定义
 */
function loadYiZhengDoctorLayerData(totalQuota,across) {
	var monitorType = "";
	if (doctorSetConfig.length > 0) {
		if(doctorSetConfig[0]==1){
			//主任医师
			monitorType = 'protomedicus';
			loadYiZhengDoctorData(totalQuota, monitorType, across) ;
		}
		if(doctorSetConfig[1]==1){
			//主诊医师
			monitorType = 'clinic';
			loadYiZhengDoctorData(totalQuota, monitorType, across);
		}
		if(doctorSetConfig[2]==1){
			//住院医师
			monitorType = 'resident';
			loadYiZhengDoctorData(totalQuota, monitorType, across);
		}
		if(doctorSetConfig[3]==1){  
			//主治医师
			monitorType = 'physician';
			loadYiZhengDoctorData(totalQuota, monitorType, across);
		}
	}
}
function loadYiZhengDoctorData(totalQuota,monitorType,across){
	for (var o in totalQuota) {
		var quotaTypes = totalQuota[o].children;
		for (var o in quotaTypes) {
			var quotas = quotaTypes[o];
			for (var o1 in quotas.children) {
				var quota = quotas.children[o1];
				var quotaCode = quota.code;
				var quotaName = quota.name;
				var quotaType = quota.type;
				var isLink = quota.islink;
				loadYiZhengDoctorDataSub(quotaCode, quotaType, quotaName,monitorType,across,isLink);
			}
		}
	}
}
/**
 * 科室调用
 * 
 * @param {}
 *            quotaCode
 * @param {}
 *            quotaName
 * @param {}
 *            monitorType
 * @param {}
 *            functionName
 */
function loadYiZhengDoctorDataSub(quotaCode, quotaType, quotaName,monitorType,across,isLink) {
	var param=drgUI.setAjaxData(tabId);
	param.monitorType=monitorType;
	param.quotaCode=quotaCode;
	$.post(contextPath + "/DrgsIndexCal/indexCal.dhc", param).done(function(data) {
			data = data.data;
			var hasCaseDtl = isLink==1?true:false;
			var columns = [
			               {  "data": "ddesc", "render" : function(obj, type, full) {
//			            	   	   // 如果不属于当前科室
				            	   if(full.isBelongTo == false) {
				            		   return "<span data-toggle=\"tooltip\" data-placement=\"right\" title=\""+full.currentDepName+"\"><font color=\"red\">"+full.ddesc+"</font></span>" ;
				            	   } else {
				            		   return full.ddesc ;
				            	   }
			               	   }
			               },
			               { "data": "QuotaValue_1", "type":"number-html",
			            	   "render": function(obj, type, full){
			            		   full.QuotaValue=full.QuotaValue!=null?full.QuotaValue:'';//强制转换
			            		   full.QuotaValuecc=full.QuotaValuecc!=null?full.QuotaValuecc:'';
		            			   if(hasCaseDtl && full.QuotaValue>0){
										return "<a href=\"javascript:loadCaseDtl('"+full.ddesc+"|"+quotaName+"','"+full.ccode+"','"+monitorType+"', '"+quotaCode+"')\">"+formatNumber(full.QuotaValue)+"</a>"
		            			   }
		            			   return "<span>"+formatNumber(full.QuotaValue)+"</span>";
			            	   }
			               },
			               { "data": "QuotaValuecc_1","type":"numeric-comma",
			            	   "render": function(obj, type, full){
		            			   return formatNumber(full.QuotaValuecc);
			            	   }
			               },
			               { "data": "increasing","type": "number-fate",
			            	   "render":function(obj, type, full){
			            		   if("ratio"==quotaType){
			            			   return gridcompareValuePercent(full.QuotaValue, full.QuotaValuecc);
			            		   }
			            		   return gridcompareValue(full.QuotaValue, full.QuotaValuecc);
			            	   }
			               },
			               { "data": "OPERATION",
			            	   "render" : function(obj, type, full) {
			            		   if(across){//交叉的情况	科室线下各病种层次	病区线下各科室层次
			            			   if(full.ccode==null){
		            					   return "<a title='入组病例' class='jumplink' href=\"javascript:alertData()\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"								
			               					+ "<a title='趋势' href=\"javascript:alertData()\" class='trend-link'><i class='fa fa-line-chart'></i></a>";
	            					   } else {
		            					   return "<a title='入组病例' class='jumplink' href=\"javascript:loadDetail('"+ full.ccode+ "','"+ full.ddesc+ "','"+ monitorType+ "')\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"								
			               					+ "<a title='趋势' href=\"javascript:trend('"+full.ccode+"', '"+full.ddesc+"', '"+monitorType+"', '"+quotaCode+"', '"+quotaName+"')\" class='trend-link'><i class='fa fa-line-chart'></i></a>";;
	            					   }
		               				}else{

			               				var operation = "";
										if (typeof (param.disBack) == "undefined") {
											if (full.ccode == null) {
												operation = "<a href=\"javascript:alertData()\"><i class='fa fa-list-alt'></i></a>&nbsp;";
											} else {
												operation = "<a title='病组' class='jumplink' href=\"javascript:loadDRGs('"+ full.ccode+ "','"+ full.ddesc+ "','"+ monitorType+ "')\"><i class='fa fa-list-alt'></i></a>&nbsp;&nbsp;";
											}
										}
			               				if(full.ccode==null){
		               						return operation
			               					+ "<a title='入组病例' class='jumplink' href=\"javascript:alertData()\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"								
			               					+ "<a title='趋势' class='trend-link' href=\"javascript:alertData()\"><i class='fa fa-line-chart'></i></a>" ;
	               						}else{
		               						return operation
			               					+ "<a title='入组病例' class='jumplink' href=\"javascript:loadDetail('"+ full.ccode+ "','"+ full.ddesc+ "','"+ monitorType+ "')\"><i class='fa fa-users'></i></a>&nbsp;&nbsp;"								
			               					+ "<a title='趋势' href=\"javascript:trend('"+full.ccode+"', '"+full.ddesc+"', '"+monitorType+"', '"+quotaCode+"', '"+quotaName+"')\" class='trend-link'><i class='fa fa-line-chart'></i></a>";
	               						}
		               				}
			            	   }
			               }
		               ];
			var tabledata = null ;
			$.when(isBelongToDep(monitorType,data)).done(function(){
				var paramsDataTables={order:[],columnDefs:[{"orderable": false,"targets":[4] }]};
				tabledata = $("#"+quotaCode+"-table"+tabId+monitorType).drgsDataTable(columns, data, paramsDataTables);
			})
	})
}

/**
 * 过滤所有的节点，只返回指标节点
 * @param node
 * @returns
 */
function quotaFilter(node) {
	var re=/[-]/g;
	if(node.id != "" && node.id != null && node.checked){
		var nodeId = node.id;
		if(re.test(nodeId)){
			var n=nodeId.match(re).length;
			if(n == 2){
				pageQuotaNodesNew.push(node.code);
			}
		}
	}
	return node;
}

// 获取科室等相关信息,用于将所在科室编码映射成描述
loadDepRelatedInfoByConfig () ;
// 获取科室所辖病组
function findDepartmentDRGs(){
	depdrgCodeIsTreatment = [] ;
	//获取所有科室组列表
	var param=drgUI.setAjaxData(tabId);
	$.ajax({
		url : contextPath + "/Department/findDepartmentDRGs.dhc",
		type : "post",
		dataType : "json",
		async : false ,
		data:param,
		success : function(data) {
			data = data.data ;
			for(var o in data) {
				depdrgCodeIsTreatment.push(data[o].DEPCODE+"-"+data[o].DRGCODE) ;
			}
		}
	})
} 

// 保存科室病病组关系
var depdrgCodeIsTreatment = null ;
/**
 * 是否应治疗
 */
function isTreatment(tableData){
	var param=drgUI.setAjaxData(tabId);
	var depCode = param.pardepCode ;
	for(var o in tableData) {
		if($.inArray(depCode+"-"+tableData[o].ccode,depdrgCodeIsTreatment) == -1) {
			tableData[o].isTreatment = 0 ;
		} else {
			tableData[o].isTreatment = 1 ;
		}
	}
}